<?php echo $header; ?>

 

<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>

<script type="text/javascript" src="catalog/view/javascript/cookie.js"></script>
<div style="width:100%;border:1px solid">
<div id='number_street_xstreet' style="width:100%;" >
<button onclick='lookup_location(); return false;'>找到我!</button>   
<form action='<?php echo $action; ?>' method='POST' id='form_1'>
            <table>
                <!-- For English, we want the number before the street, for Chinese, after -->

                    <tr>
                        <td><label for='street'>路名</label></td>
                        <td><input id='street' type='text'></input></td>
                        <td>例如: 辽源路</td>
                    </tr>               
                    <tr>
                        <td><label for='number'>门牌号</label></td>
                        <td><input id='number' type='text'></input></td>
                        <td>例如: 257号</td>
                    </tr>
                

           
            </table>

       <a onclick='lookup_location()' >找到我</a>
      <a onclick="$('#form_1').submit()">提交</a>
	 </form>
	   
    </div>
	<div id='store_list'></div>
	</div>
	<script type="text/javascript">


	function RndNum(n){
		var rnd="";
		for(var i=0;i<n;i++)
		{
			rnd+=Math.floor(Math.random()*10);
		}
		
		return rnd;
	}
	
	function lookup_location() {
 
			var position;

            var number = document.getElementById('number').value;
            var street = document.getElementById('street').value;
            

			var citys = '青岛';
			var address = street+number;
			
			
			// 创建地址解析器实例
			var myGeo = new BMap.Geocoder();
			
			myGeo.getPoint(address, function(point){
			  if (point) {

				position = point;
				//alert(position.lat+','+position.lng);
				
				$.ajax({
				    type: "GET",
					dataType: 'json',
				    url: "index.php?route=stores/getnearbystores",
				    data: "positionlat="+position.lat+"&positionlng="+position.lng,
				    success: function(strJosn){
						 strJosn = eval(strJosn);
						for(var i=0; i<strJosn.length; i++)
						{
						  var html = "<ul>";
						  html += "<li onclick = locationtoNearbyStore('"+strJosn[i].store_url+"')>";
						  html += strJosn[i].name;
						  html += "</li>";
						  html += "</ul>";
						  
						  $('#store_list').append(html);
						}
				    }
				});
				
			  }else{
				alert(您输入的地址不正确);
			  }
			}, citys);

			
    }
	function locationtoNearbyStore(url){
		window.location.href=url;
	}
</script>



	<?php echo $footer; ?>
